import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';
import '../../../routes/app_pages.dart';
import '../../../style/app_colors.dart';
import '../controllers/bindtip_controller.dart';

// 找不到服务.
const String ERROR_NO_FOUND_SERVICES = 'ERROR_NO_FOUND_SERVICES';
// 连接中断
const String ERROR_CONNECTION_INTERUPTED = 'ERROR_CONNECTION_INTERUPTED';
// 被绑定
const String ERROR_BINDING_ACCOUNT = 'ERROR_BINDING_ACCOUNT';
// 网络配网失败.
//const String NET_WORK_CONFIG_FAILURE = 'NET_WORK_CONFIG_FAILURE';
//设备不存在.
const String DEVICE_SN_NO_EXISTANCE = 'DEVICE_SN_NO_EXISTANCE';

//wifi
const String WIFI_UNVAILABLE_ERROR = 'WIFI_UNVAILABLE_ERROR';
const String WIFI_PASSWORD_UNVAILABLE_ERROR = 'WIFI_PASSWORD_UNVAILABLE_ERROR';


class BindtipView extends GetView<BindtipController> {
  const BindtipView({super.key});
  @override
  Widget build(BuildContext context) {
     return Scaffold(
        appBar: AppBar(
          leading: IconButton(
            icon: Image.asset('assets/images/ic_back2.png',width: 48.w,height: 48.h),
            onPressed: () {
              // eventBus.fire(ProductContentEvent(BLUE_DEVICE_CONNECTED_AGAIN));
              // Get.offNamed(Routes.POWER_ONING);
              Get.back();
            }
          ),
          /*leading: SizedBox(),*/
        ),
        body:  Obx(()=> Center(
          child: Container(
            padding: EdgeInsets.all(20),
            child: controller.errorType.value == ERROR_NO_FOUND_SERVICES ? Column(
              children: [
                SizedBox(height: 363.h),
                Image.asset('assets/images/binding_failure_1.webp',width: 270.w,height: 270.h),
                SizedBox(height: 32.h),
                Text('蓝牙发现服务失败,请重新尝试.',style: TextStyle(fontSize: 28.sp,color: AppColors.newEditFieldHintText_color),),
                SizedBox(height: 440.h),
                Container(
                  width: 594.w,
                  child: ElevatedButton(onPressed: () {
                    Get.offAllNamed(Routes.HOME);

                  }, child: Text('进入首页')),
                )
              ],
            ) : controller.errorType.value == ERROR_CONNECTION_INTERUPTED ? Column(
              children: [
                SizedBox(height: 363.h),
                Image.asset('assets/images/ic_error_time_out.webp',width: 270.w,height: 270.h),
                SizedBox(height: 32.h),
                Text('绑定超时,请重新尝试.',style: TextStyle(fontSize: 28.sp,color: AppColors.newEditFieldHintText_color),),
                SizedBox(height: 440.h),
                Container(
                  width: 594.w,
                  child: ElevatedButton(onPressed: () {
                    Get.offAllNamed(Routes.HOME);

                  }, child: Text('进入首页')),
                )
              ],
            ) : controller.errorType.value == ERROR_BINDING_ACCOUNT ? Column(
              children: [
                SizedBox(height: 363.h),
                Image.asset('assets/images/mini_bebound.webp',width: 270.w,height: 270.h),
                SizedBox(height: 32.h),
                Text('悟空机器人已经被${controller.wkMasterUserName.value}绑定',style: TextStyle(fontSize: 28.sp,color: AppColors.newEditFieldHintText_color),),
                SizedBox(height: 440.h),
                Container(
                  width: 594.w,
                  child: ElevatedButton(onPressed: () {
                    Get.offAllNamed(Routes.HOME);

                  }, child: Text('进入首页')),
                )
              ],
            ) : controller.errorType.value == DEVICE_SN_NO_EXISTANCE ? Column(
              children: [
                SizedBox(height: 363.h),
                Image.asset('assets/images/binding_failure_1.webp',width: 270.w,height: 270.h),
                SizedBox(height: 32.h),
                Text('序列号${controller.wkSN.value}不存在,请联系客服处理',style: TextStyle(fontSize: 28.sp,color: AppColors.newEditFieldHintText_color),),
                SizedBox(height: 440.h),
                Container(
                  width: 594.w,
                  child: ElevatedButton(onPressed: () {
                    Get.offAllNamed(Routes.HOME);

                  }, child: Text('进入首页')),
                )
              ],
            ) : controller.errorType.value == WIFI_UNVAILABLE_ERROR ? Column(
              children: [
                SizedBox(height: 363.h),
                Image.asset('assets/images/no_wifi_unavailable.png',width: 270.w,height: 270.h),
                SizedBox(height: 32.h),
                Text('此Wi-Fi不可用,请换一个吧',style: TextStyle(fontSize: 28.sp,color: AppColors.newEditFieldHintText_color),),
                SizedBox(height: 440.h),
                Container(
                  width: 594.w,
                  child: ElevatedButton(onPressed: () {
                    Get.offAllNamed(Routes.HOME);

                  }, child: Text('进入首页')),
                )
              ],
            )  : controller.errorType.value == WIFI_PASSWORD_UNVAILABLE_ERROR ? Column(
              children: [
                SizedBox(height: 363.h),
                Image.asset('assets/images/ic_wifi_wrong_password.webp',width: 270.w,height: 270.h),
                SizedBox(height: 32.h),
                Text('Wi-Fi密码错误,请重新输入',style: TextStyle(fontSize: 28.sp,color: AppColors.newEditFieldHintText_color),),
                SizedBox(height: 440.h),
                Container(
                  width: 594.w,
                  child: ElevatedButton(onPressed: () {
                    Get.offAllNamed(Routes.HOME);

                  }, child: Text('进入首页')),
                )
              ],
            ) : Column(
              children: [
                SizedBox(height: 363.h),
                Image.asset('assets/images/mini_bebound.webp',width: 270.w,height: 270.h),
                SizedBox(height: 32.h),
                Text('未知错误,请重新尝试.',style: TextStyle(fontSize: 28.sp,color: AppColors.newEditFieldHintText_color),),
                SizedBox(height: 440.h),
                Container(
                  width: 594.w,
                  child: ElevatedButton(onPressed: () {
                    Get.offAllNamed(Routes.HOME);

                  }, child: Text('进入首页')),
                )
              ],
            ) ,
          ),
        )),
      );
  }
}
